<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div class="text-right">
	<ul class="pagination pagination-sm">
		<li><a href="javascript:_gotoPage(1);" title="首页">首页</a></li>
		&nbsp;
		<li><a href="javascript:_gotoPage(${page.prePage});" title="上一页">上一页</a></li>
		<c:choose>
			<c:when test="${page.pageNo <=4}">
				<c:if test="${page.totalPage<=8 }" >
					<c:forEach varStatus="pag" begin="1" end="${page.totalPage}" step="1"> 
					<li <c:if test="${pag.index==page.pageNo}" > class="active" </c:if>><a href="javascript:_gotoPage(${pag.index});" title="${pag.index }">${pag.index }</a></li>
					</c:forEach>
				</c:if>
				<c:if test="${page.totalPage>8 }" >
					<c:forEach varStatus="pag" begin="1" end="9" step="1"> 
					<li <c:if test="${pag.index==page.pageNo}" > class="active" </c:if>><a href="javascript:_gotoPage(${pag.index});" title="${pag.index }">${pag.index }</a></li>
					</c:forEach>
				</c:if>
			</c:when>
			<c:otherwise>
				<c:if test="${page.totalPage<=8 }" >
					<c:forEach varStatus="pag" begin="1" end="${page.totalPage}" step="1"> 
					<li <c:if test="${pag.index==page.pageNo}" > class="active" </c:if>><a href="javascript:_gotoPage(${pag.index});" title="${pag.index }">${pag.index }</a></li>
					</c:forEach>
				</c:if>
				<c:if test="${page.totalPage>8 }" >
					<c:forEach varStatus="pag" begin="${page.pageNo+4>=page.totalPage?page.totalPage-8 : page.pageNo-4 }" end="${page.pageNo+4>=page.totalPage?page.totalPage : page.pageNo+4 }" step="1"> 
					<li <c:if test="${pag.index==page.pageNo}" > class="active" </c:if>><a href="javascript:_gotoPage(${pag.index});" title="${pag.index }">${pag.index }</a></li>
					</c:forEach>
				</c:if>
			</c:otherwise>
		</c:choose>
		<li><a href="javascript:_gotoPage(${page.nextPage});" title="下一页">下一页</a></li>
		<li><a href="javascript:_gotoPage(${page.totalPage});" title="末页">末页</a></li>
		<li title="跳转到">
	  		<span style="padding:0;margin:0;height:30px;border-left:none;" >
	  			<input type="text" name="goNumber" id="goNumber" style="text-align:center;border:none;width:48px;height:28px;line-height:28px;font-size:12px;padding:0;margin:0;"/>
	  		</span>
	  	</li>
	  	<li><a href="javascript:go()">GO</a></li>
		<li><a href="javascript:void(0);"> 共${page.totalPage}页 | 每页${page.pageSize}条 | 共${page.totalCount}条记录</a></li>
	</ul>
</div>

<input type="hidden" id="pageNo" name="pageNo" value="${page.pageNo}" />
<input type="hidden" id="pageSize" name="pageSize" value="${page.pageSize}" />
<input type="hidden" id="pageTotalCount" name="pageTotalCount" value="${page.totalCount}" />
<script type="text/javascript">
function goPageSearch(){
	$('#pageNo').val('1');	
	$('#pageTotalCount').val('');	
	$('#dataForm').submit();
}
function go(){
	if(!isNaN($("#goNumber").val())){
		if($("#goNumber").val()>0 && $("#goNumber").val() <= ${page.totalPage}){
			_gotoPage($("#goNumber").val());
		}else{
			ui.msg.warning('页码输入错误');
		}
	}else{
		ui.msg.warning('页码只能是数字');
		$("#goNumber").val('');
	}
}
function _gotoPage(pageNo) {
	try{
		var formPageNo = $("#pageNo")
		var tableForm = $(formPageNo).closest("form");
		if(pageNo){
			$("#pageNo").val(pageNo);
		}else{
			$("#pageNo").val(1);
		}
		tableForm.onsubmit=null;
		tableForm.submit();
	} catch(e) {
		alert('_gotoPage(pageNo)方法出错');
	}
}
</script>
